package dataDetail;

import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Text;

import dataNode.DataNodeDesc;

import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Spinner;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.widgets.List;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;

public class DataDetail extends Group {

	private Text text;
	private Text text_1;
	private Text text_2;
	private Text text_3;
	private Text text_5;
	private Text text_6;
	private Combo combo;
	private Spinner spinner;
	private Spinner spinner_1;
	private Spinner spinner_2;
	private Button btnCheckButton;
	private List list;
	
	public void setData(DataNodeDesc dnd) {
		this.text.setText(dnd.getCname());
		this.text_1.setText(dnd.getId());
		//this.text_2.setText(dnd.getDataForm());
		/*this.text.setText(stext);
		this.text_1.setText(stext_1);
		this.text_2.setText(stext_2);
		this.text_3.setText(stext_3);
		this.spinner.setTextDirection(sspinner);
		this.spinner_1.setTextDirection(ssPinner_1);
		this.spinner_2.setTextDirection(sspinner_2);
		this.btnCheckButton.setSelection(sbtnCheckButton);
		this.list=slist;*/
	}
	
	
	/**
	 * Create the composite.
	 * @param parent
	 * @param style
	 */
	public DataDetail(Composite parent, int style) {
		super(parent, style);
		setText("\u5B57\u6BB5\u8BE6\u60C5");
		setLayout(new FormLayout());
		
		Label lblNewLabel = new Label(this, SWT.NONE);
		FormData fd_lblNewLabel = new FormData();
		fd_lblNewLabel.right = new FormAttachment(0, 103);
		fd_lblNewLabel.top = new FormAttachment(0, 10);
		fd_lblNewLabel.left = new FormAttachment(0, 27);
		lblNewLabel.setLayoutData(fd_lblNewLabel);
		lblNewLabel.setAlignment(SWT.RIGHT);
		lblNewLabel.setText("\u5B57\u6BB5\u540D\u79F0\uFF1A");
		
		text = new Text(this, SWT.BORDER);
		FormData fd_text = new FormData();
		fd_text.right = new FormAttachment(0, 423);
		fd_text.top = new FormAttachment(0, 7);
		fd_text.left = new FormAttachment(0, 107);
		text.setLayoutData(fd_text);
		
		Label lblNewLabel_1 = new Label(this, SWT.NONE);
		FormData fd_lblNewLabel_1 = new FormData();
		fd_lblNewLabel_1.right = new FormAttachment(0, 103);
		fd_lblNewLabel_1.top = new FormAttachment(0, 45);
		fd_lblNewLabel_1.left = new FormAttachment(0, 27);
		lblNewLabel_1.setLayoutData(fd_lblNewLabel_1);
		lblNewLabel_1.setAlignment(SWT.RIGHT);
		lblNewLabel_1.setText("\u4E2D\u6587\u540D\u79F0\uFF1A");
		
		text_1 = new Text(this, SWT.BORDER);
		FormData fd_text_1 = new FormData();
		fd_text_1.right = new FormAttachment(0, 423);
		fd_text_1.top = new FormAttachment(0, 45);
		fd_text_1.left = new FormAttachment(0, 107);
		text_1.setLayoutData(fd_text_1);
		
		Label lblNewLabel_2 = new Label(this, SWT.NONE);
		FormData fd_lblNewLabel_2 = new FormData();
		fd_lblNewLabel_2.right = new FormAttachment(0, 103);
		fd_lblNewLabel_2.top = new FormAttachment(0, 80);
		fd_lblNewLabel_2.left = new FormAttachment(0, 27);
		lblNewLabel_2.setLayoutData(fd_lblNewLabel_2);
		lblNewLabel_2.setAlignment(SWT.RIGHT);
		lblNewLabel_2.setText("\u6570\u636E\u683C\u5F0F\uFF1A");
		
		text_2 = new Text(this, SWT.BORDER);
		FormData fd_text_2 = new FormData();
		fd_text_2.right = new FormAttachment(0, 423);
		fd_text_2.top = new FormAttachment(0, 80);
		fd_text_2.left = new FormAttachment(0, 107);
		text_2.setLayoutData(fd_text_2);
		
		Label lblNewLabel_3 = new Label(this, SWT.NONE);
		FormData fd_lblNewLabel_3 = new FormData();
		fd_lblNewLabel_3.right = new FormAttachment(0, 103);
		fd_lblNewLabel_3.top = new FormAttachment(0, 115);
		fd_lblNewLabel_3.left = new FormAttachment(0, 27);
		lblNewLabel_3.setLayoutData(fd_lblNewLabel_3);
		lblNewLabel_3.setAlignment(SWT.RIGHT);
		lblNewLabel_3.setText("\u7C7B\u578B\uFF1A");
		
		combo = new Combo(this, SWT.NONE);
		FormData fd_combo = new FormData();
		fd_combo.right = new FormAttachment(0, 423);
		fd_combo.top = new FormAttachment(0, 115);
		fd_combo.left = new FormAttachment(0, 107);
		combo.setLayoutData(fd_combo);
		
		Label lblNewLabel_4 = new Label(this, SWT.NONE);
		FormData fd_lblNewLabel_4 = new FormData();
		fd_lblNewLabel_4.right = new FormAttachment(0, 103);
		fd_lblNewLabel_4.top = new FormAttachment(0, 150);
		fd_lblNewLabel_4.left = new FormAttachment(0, 27);
		lblNewLabel_4.setLayoutData(fd_lblNewLabel_4);
		lblNewLabel_4.setAlignment(SWT.RIGHT);
		lblNewLabel_4.setText("\u957F\u5EA6\uFF1A");
		
		spinner = new Spinner(this, SWT.BORDER);
		FormData fd_spinner = new FormData();
		fd_spinner.right = new FormAttachment(0, 423);
		fd_spinner.top = new FormAttachment(0, 150);
		fd_spinner.left = new FormAttachment(0, 107);
		spinner.setLayoutData(fd_spinner);
		
		Label label = new Label(this, SWT.NONE);
		FormData fd_label = new FormData();
		fd_label.right = new FormAttachment(0, 103);
		fd_label.top = new FormAttachment(0, 185);
		fd_label.left = new FormAttachment(0, 27);
		label.setLayoutData(fd_label);
		label.setAlignment(SWT.RIGHT);
		label.setText("\u6700\u5C0F\u957F\u5EA6\uFF1A");
		
		spinner_1 = new Spinner(this, SWT.BORDER);
		FormData fd_spinner_1 = new FormData();
		fd_spinner_1.right = new FormAttachment(0, 423);
		fd_spinner_1.top = new FormAttachment(0, 185);
		fd_spinner_1.left = new FormAttachment(0, 107);
		spinner_1.setLayoutData(fd_spinner_1);
		
		Label label_1 = new Label(this, SWT.NONE);
		FormData fd_label_1 = new FormData();
		fd_label_1.right = new FormAttachment(0, 103);
		fd_label_1.top = new FormAttachment(0, 220);
		fd_label_1.left = new FormAttachment(0, 27);
		label_1.setLayoutData(fd_label_1);
		label_1.setAlignment(SWT.RIGHT);
		label_1.setText("\u7CBE\u5EA6\uFF1A");
		
		spinner_2 = new Spinner(this, SWT.BORDER);
		FormData fd_spinner_2 = new FormData();
		fd_spinner_2.right = new FormAttachment(0, 423);
		fd_spinner_2.top = new FormAttachment(0, 220);
		fd_spinner_2.left = new FormAttachment(0, 107);
		spinner_2.setLayoutData(fd_spinner_2);
		
		Label label_3 = new Label(this, SWT.NONE);
		FormData fd_label_3 = new FormData();
		fd_label_3.right = new FormAttachment(0, 107);
		fd_label_3.top = new FormAttachment(0, 255);
		fd_label_3.left = new FormAttachment(0, 7);
		label_3.setLayoutData(fd_label_3);
		label_3.setAlignment(SWT.RIGHT);
		label_3.setText("\u6B63\u5219\u8868\u8FBE\u5F0F\uFF1A");
		
		text_3 = new Text(this, SWT.BORDER);
		FormData fd_text_3 = new FormData();
		fd_text_3.right = new FormAttachment(0, 319);
		fd_text_3.top = new FormAttachment(0, 255);
		fd_text_3.left = new FormAttachment(0, 107);
		text_3.setLayoutData(fd_text_3);
		
		Button btnNewButton = new Button(this, SWT.NONE);
		FormData fd_btnNewButton = new FormData();
		fd_btnNewButton.right = new FormAttachment(0, 425);
		fd_btnNewButton.top = new FormAttachment(0, 255);
		fd_btnNewButton.left = new FormAttachment(0, 327);
		btnNewButton.setLayoutData(fd_btnNewButton);
		btnNewButton.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				RegexTestBox rtb=new RegexTestBox(parent.getShell(), SWT.DIALOG_TRIM);
				String rexResultText=(String) rtb.open(text_3.getText());
				text_3.setText(rexResultText);
			}
		});
		btnNewButton.setText("\u7F16\u8F91");
		
		Label lblNewLabel_5 = new Label(this, SWT.NONE);
		FormData fd_lblNewLabel_5 = new FormData();
		fd_lblNewLabel_5.right = new FormAttachment(0, 83);
		fd_lblNewLabel_5.top = new FormAttachment(0, 300);
		fd_lblNewLabel_5.left = new FormAttachment(0, 7);
		lblNewLabel_5.setLayoutData(fd_lblNewLabel_5);
		lblNewLabel_5.setText("\u7279\u6B8A\u6807\u8BC6\uFF1A");
		
		btnCheckButton = new Button(this, SWT.CHECK);
		FormData fd_btnCheckButton = new FormData();
		fd_btnCheckButton.right = new FormAttachment(0, 225);
		fd_btnCheckButton.top = new FormAttachment(0, 300);
		fd_btnCheckButton.left = new FormAttachment(0, 104);
		btnCheckButton.setLayoutData(fd_btnCheckButton);
		btnCheckButton.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
			}
		});
		btnCheckButton.setText("\u654F\u611F\u5B57\u6BB5");
		
		Label label_4 = new Label(this, SWT.SEPARATOR | SWT.HORIZONTAL);
		FormData fd_label_4 = new FormData();
		fd_label_4.right = new FormAttachment(100, -10);
		fd_label_4.top = new FormAttachment(0, 350);
		fd_label_4.left = new FormAttachment(0, 7);
		label_4.setLayoutData(fd_label_4);
		
		Label lblNewLabel_6 = new Label(this, SWT.NONE);
		FormData fd_lblNewLabel_6 = new FormData();
		fd_lblNewLabel_6.right = new FormAttachment(0, 83);
		fd_lblNewLabel_6.top = new FormAttachment(0, 370);
		fd_lblNewLabel_6.left = new FormAttachment(0, 7);
		lblNewLabel_6.setLayoutData(fd_lblNewLabel_6);
		lblNewLabel_6.setText("\u679A\u4E3E\u9879\uFF1A");
		
		Button btnNewButton_1 = new Button(this, SWT.NONE);
		
		FormData fd_btnNewButton_1 = new FormData();
		fd_btnNewButton_1.right = new FormAttachment(0, 423);
		fd_btnNewButton_1.top = new FormAttachment(0, 408);
		fd_btnNewButton_1.left = new FormAttachment(0, 327);
		btnNewButton_1.setLayoutData(fd_btnNewButton_1);
		btnNewButton_1.setText("\u5220\u9664");
		
		Label lblNewLabel_7 = new Label(this, SWT.NONE);
		FormData fd_lblNewLabel_7 = new FormData();
		fd_lblNewLabel_7.bottom = new FormAttachment(100, -20);
		fd_lblNewLabel_7.right = new FormAttachment(0, 47);
		fd_lblNewLabel_7.top = new FormAttachment(100, -40);
		fd_lblNewLabel_7.left = new FormAttachment(0, 7);
		lblNewLabel_7.setLayoutData(fd_lblNewLabel_7);
		lblNewLabel_7.setText("Key\uFF1A");
		
		text_5 = new Text(this, SWT.BORDER);
		FormData fd_text_5 = new FormData();
		fd_text_5.top = new FormAttachment(100, -40);
		fd_text_5.left = new FormAttachment(lblNewLabel_7, 6);
		fd_text_5.right = new FormAttachment(0, 153);
		text_5.setLayoutData(fd_text_5);
		
		Label lblNewLabel_8 = new Label(this, SWT.NONE);
		FormData fd_lblNewLabel_8 = new FormData();
		fd_lblNewLabel_8.right = new FormAttachment(0, 225);
		fd_lblNewLabel_8.top = new FormAttachment(100, -40);
		fd_lblNewLabel_8.left = new FormAttachment(0, 172);
		lblNewLabel_8.setLayoutData(fd_lblNewLabel_8);
		lblNewLabel_8.setText("Value\uFF1A");
		
		text_6 = new Text(this, SWT.BORDER);
		FormData fd_text_6 = new FormData();
		fd_text_6.right = new FormAttachment(0, 333);
		fd_text_6.top = new FormAttachment(100, -40);
		fd_text_6.left = new FormAttachment(0, 233);
		text_6.setLayoutData(fd_text_6);
		
		Button btnNewButton_2 = new Button(this, SWT.NONE);
		
		FormData fd_btnNewButton_2 = new FormData();
		fd_btnNewButton_2.right = new FormAttachment(0, 405);
		fd_btnNewButton_2.top = new FormAttachment(100, -40);
		fd_btnNewButton_2.left = new FormAttachment(0, 350);
		btnNewButton_2.setLayoutData(fd_btnNewButton_2);
		btnNewButton_2.setText("\u221A");
		
		list = new List(this, SWT.BORDER);
		FormData fd_list = new FormData();
		fd_list.bottom = new FormAttachment(100, -50);
		fd_list.right = new FormAttachment(text_3, 0, SWT.RIGHT);
		fd_list.top = new FormAttachment(btnNewButton_1, 1, SWT.TOP);
		fd_list.left = new FormAttachment(lblNewLabel, 0, SWT.LEFT);
		list.setLayoutData(fd_list);
		
		btnNewButton_2.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseDown(MouseEvent e) {
				String key = text_5.getText();
				String value=text_6.getText();
				if(key!=null && !key.equals("")) {
					list.add(key+"-"+value);
					text_5.setText("");
					text_6.setText("");
				}
			}
		});
		
		btnNewButton_1.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseDown(MouseEvent e) {
				int selectlist=list.getSelectionIndex();
				list.remove(selectlist);
			}
		});
		
	}

	@Override
	protected void checkSubclass() {
		// Disable the check that prevents subclassing of SWT components
	}

}
